home *** CD-ROM | disk | FTP | other *** search
/ Nikkei Mac 11 / NIKKEI-MAC-CD-VOL-11-1998-03.ISO.7z / NIKKEI-MAC-CD-VOL-11-1998-03.ISO / オンラインソフト / 3.デスクトップを楽しく / DarkSide of the Mac 4.2.sit / DarkSide of the Mac 4.2 / SampleFaders / Invert.c < prev    next >
Text File  |  1994-08-18  |  3KB  |  136 lines

  1. /*
  2.     DarkSide 3.0 - a 7.0 dependant, system clean expandable screen saver.
  3.     
  4.     copyright ゥハ1990, 1991, 1992 by Tom Dowdy
  5.     All rights reserved.
  6.  
  7.     This is a simple fader that shows how to create a fader for DarkSide.
  8. */
  9. #include <Memory.h>
  10. #include <Windows.h>
  11. #include <Dialogs.h>
  12. #include <Errors.h>
  13.  
  14. #include "Fader.h"
  15.  
  16. /* ------------------------------------------------------------------------    */
  17. /* GLOBAL VARIABLES */
  18. /* ------------------------------------------------------------------------    */
  19. long        gNextInvert;            // next time to invert the screens
  20.  
  21. /* ------------------------------------------------------------------------    */
  22. OSErr    PreflightFader(MachineInfoPtr machineInfo, long *minTicks, long *maxTicks)
  23. /*
  24.     Called when fader is starting up - before window has been created
  25. */
  26. {
  27. #pragma unused (machineInfo)
  28.     
  29.     // no need to go faster than this!
  30.     *minTicks = 1;
  31.     *maxTicks = 15;
  32.     
  33.     return(noErr);
  34.     
  35. } // PreflightFader
  36.  
  37. /* ------------------------------------------------------------------------    */
  38. OSErr    InitializeFader(MachineInfoPtr machineInfo)
  39. /*
  40.     Called when fader is starting up - after window has been created
  41. */
  42. {
  43.     short            screenIndex;
  44.     ScreenInfoPtr    pScreen;
  45.     
  46.  
  47.     pScreen = &machineInfo->theScreens[0];
  48.     for (screenIndex = 0; screenIndex < machineInfo->numScreens; ++screenIndex)
  49.         {
  50.         PaintRect(&pScreen->bounds);
  51.             
  52.         ++pScreen;
  53.         }
  54.         
  55.     gNextInvert = TickCount();
  56.     
  57.     return(noErr);
  58.     
  59. } // InitializeFader
  60.  
  61. /* ------------------------------------------------------------------------    */
  62. OSErr    IdleFader(MachineInfoPtr machineInfo)
  63. /*
  64.     Called during idle time for the fader
  65. */
  66. {
  67.     short            screenIndex;
  68.     ScreenInfoPtr    pScreen;
  69.     
  70.  
  71.     if (TickCount() > gNextInvert)
  72.         {
  73.         pScreen = &machineInfo->theScreens[0];
  74.         for (screenIndex = 0; screenIndex < machineInfo->numScreens; ++screenIndex)
  75.             {
  76.             if (Random() & 0x01)
  77.                 InvertRect(&pScreen->bounds);
  78.                 
  79.             ++pScreen;
  80.             }
  81.  
  82.         gNextInvert = TickCount() 
  83.             + (9-machineInfo->faderSettings->theShorts[0]) * 10;
  84.         }
  85.         
  86.     return(noErr);
  87.     
  88. } // IdleFader
  89.  
  90.  
  91. /* ------------------------------------------------------------------------    */
  92. OSErr    DisposeFader(MachineInfoPtr machineInfo)
  93. /*
  94.     Called when the fade is tearing down
  95. */
  96. {
  97. #pragma unused (machineInfo)
  98.  
  99.     return(noErr);
  100.     
  101. } // DisposeFader
  102.  
  103. /* ------------------------------------------------------------------------    */
  104. OSErr    UpdateFader(MachineInfoPtr machineInfo)
  105. /*
  106.     Called when there is an update event for our fade window.
  107. */
  108. {
  109.     // erase the screen
  110.     InitializeFader(machineInfo);
  111.     return(noErr);
  112.     
  113. } // UpdateFader
  114.  
  115. /* ------------------------------------------------------------------------    */
  116. OSErr    HitFader(MachineInfoPtr machineInfo, DialogPtr dPtr, short itemHit, short itemOffset)
  117. /*
  118.     Called when there is an event in the settings dialog.  itemHit will be
  119.     the item the user has selected, or 0 when the dialog is being set up.
  120.     
  121.     itemHit - itemOffset will allow you to determine which item in your dialog
  122.     list this corresponds to.
  123.     
  124.     If you don't wish to do any special processing of this event, simply return
  125.     "fnfErr" and the standard effect will take place.
  126.     
  127.     WARNING: Your A5 world may not be set up at this point, so don't try to use
  128.     your global variables!!!
  129. */
  130. {
  131. #pragma unused (machineInfo, dPtr, itemHit, itemOffset)
  132.  
  133.     return(fnfErr);
  134.     
  135. } // HitFader
  136.